package com.xuce.nzshop.goods.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xuce.nzshop.goods.service.GoodsService;
import com.xuce.pojo.TProduct;
import org.springframework.context.annotation.Scope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 徐策
 * @date 2020/3/16 22:11
 */
@RestController
@Scope("prototype")
public class GoodsController {
    @Resource
    GoodsService goodsService;

    /**
     * 01-全部查询商品
     *
     * @return
     */
    @GetMapping("/goods_list/{category1Id}")
    public List<TProduct> getGoodsByCategory1Id(@PathVariable Long category1Id) {
        return goodsService.list(new QueryWrapper<TProduct>()
                .eq("category1_Id", category1Id)
                .eq("is_delete", 0)
                .eq("is_marketable", 1)
                .orderByDesc("id")
                .last("limit 0,6"));
    }
}